Skip to content

Comments

feat(tip-1004): add EIP-2612 permit to TIP-20 precompile#2748

Merged
howydev merged 19 commits intomainfrom
howy/add-permit
Feb 23, 2026
Merged

feat(tip-1004): add EIP-2612 permit to TIP-20 precompile#2748
howydev merged 19 commits intomainfrom
howy/add-permit

Conversation

@howydev
Copy link
Contributor

@howydev howydev commented Feb 17, 2026

Implements TIP-1004: adds permit(), nonces(), and DOMAIN_SEPARATOR() to TIP-20 precompile (EIP-2612).

  • Gated behind T2 hardfork
  • Includes Solidity reference implementation
  • Comprehensive test coverage

Implements permit(), nonces(), and DOMAIN_SEPARATOR() for TIP-20
tokens, gated behind the T2 hardfork. Only EOA signatures are
supported (no EIP-1271).

Includes Solidity reference implementation and comprehensive tests.

Amp-Thread-ID: https://ampcode.com/threads/T-019c6da0-59df-709e-ba03-6613b5571b2d
Co-authored-by: Amp <amp@ampcode.com>
@github-actions
Copy link

github-actions bot commented Feb 17, 2026

📊 Tempo Precompiles Coverage

precompiles

Coverage: 20727/21757 lines (95.27%)

File details
File Lines Coverage
src/account_keychain/dispatch.rs 36/41 87.80%
src/account_keychain/mod.rs 1131/1150 98.35%
src/error.rs 139/158 87.97%
src/ip_validation.rs 10/10 100.00%
src/lib.rs 328/339 96.76%
src/nonce/dispatch.rs 19/23 82.61%
src/nonce/mod.rs 252/260 96.92%
src/stablecoin_dex/dispatch.rs 349/353 98.87%
src/stablecoin_dex/error.rs 51/51 100.00%
src/stablecoin_dex/mod.rs 2971/3067 96.87%
src/stablecoin_dex/order.rs 362/362 100.00%
src/stablecoin_dex/orderbook.rs 651/683 95.31%
src/storage/evm.rs 321/347 92.51%
src/storage/hashmap.rs 128/140 91.43%
src/storage/mod.rs 5/5 100.00%
src/storage/packing.rs 526/552 95.29%
src/storage/thread_local.rs 146/195 74.87%
src/storage/types/array.rs 211/262 80.53%
src/storage/types/bytes_like.rs 323/338 95.56%
src/storage/types/mapping.rs 148/148 100.00%
src/storage/types/mod.rs 67/91 73.63%
src/storage/types/primitives.rs 564/567 99.47%
src/storage/types/set.rs 454/474 95.78%
src/storage/types/slot.rs 282/296 95.27%
src/storage/types/vec.rs 1078/1095 98.45%
src/test_util.rs 194/231 83.98%
src/tip20/dispatch.rs 584/616 94.81%
src/tip20/mod.rs 1783/1854 96.17%
src/tip20/rewards.rs 444/487 91.17%
src/tip20/roles.rs 187/206 90.78%
src/tip20_factory/dispatch.rs 26/29 89.66%
src/tip20_factory/mod.rs 543/555 97.84%
src/tip403_registry/dispatch.rs 406/443 91.65%
src/tip403_registry/mod.rs 1338/1423 94.03%
src/tip_fee_manager/amm.rs 1111/1147 96.86%
src/tip_fee_manager/dispatch.rs 278/289 96.19%
src/tip_fee_manager/mod.rs 495/510 97.06%
src/validator_config/dispatch.rs 210/221 95.02%
src/validator_config/mod.rs 604/658 91.79%
src/validator_config_v2/dispatch.rs 201/214 93.93%
src/validator_config_v2/mod.rs 1771/1867 94.86%

contracts

Coverage: 209/383 lines (54.57%)

File details
File Lines Coverage
src/lib.rs 1/71 1.41%
src/precompiles/account_keychain.rs 24/30 80.00%
src/precompiles/nonce.rs 9/18 50.00%
src/precompiles/stablecoin_dex.rs 36/48 75.00%
src/precompiles/tip20.rs 52/70 74.29%
src/precompiles/tip20_factory.rs 6/12 50.00%
src/precompiles/tip403_registry.rs 12/15 80.00%
src/precompiles/tip_fee_manager.rs 21/45 46.67%
src/precompiles/validator_config.rs 12/26 46.15%
src/precompiles/validator_config_v2.rs 36/48 75.00%

Total: 20936/22140 lines (94.56%)

📦 Download full HTML report

howydev and others added 5 commits February 17, 2026 22:06
The TIP20 struct field was renamed from `_nonces` to `permit_nonces`,
but the storage layout tests still referenced `nonces`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@howydev howydev marked this pull request as ready for review February 18, 2026 04:43
howydev and others added 5 commits February 18, 2026 00:03
vm.skip() inside an invariant handler causes [FAIL: skipped] in Foundry.
Use vm.assume(!isTempo) to discard the fuzz run instead.

Also formats all PR-changed Solidity files.

Amp-Thread-ID: https://ampcode.com/threads/T-019c6f1f-917c-75d8-a908-1621cd459d6f
Co-authored-by: Amp <amp@ampcode.com>
The file was accidentally deleted, causing test_tip20_layout to fail
when solc is not available (CI and most dev environments).

Amp-Thread-ID: https://ampcode.com/threads/T-019c6f1f-917c-75d8-a908-1621cd459d6f
Co-authored-by: Amp <amp@ampcode.com>
Restores the original file from main and only changes the 'nonces'
label to 'permitNonces' to match the Rust field name (permit_nonces
-> permitNonces via camelCase conversion).

Amp-Thread-ID: https://ampcode.com/threads/T-019c6f1f-917c-75d8-a908-1621cd459d6f
Co-authored-by: Amp <amp@ampcode.com>
@howydev howydev changed the title WIP: feat(tip-1004): add EIP-2612 permit to TIP-20 precompile feat(tip-1004): add EIP-2612 permit to TIP-20 precompile Feb 18, 2026
Copy link
Member

@fgimenez fgimenez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, some nits

Copy link
Member

@fgimenez fgimenez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferring to others about invariant tests, otherwise lgtm

… tests (#2786)

## Summary

Addresses [ZELLIC-53](https://linear.app/tempoxyz/issue/ZELLIC-53):
audit findings on TIP-1004 permit implementation.

### Changes

**Bug fix — zero-address recovery rejection**

`permit()` now explicitly rejects `recovered == address(0)` before
comparing against `owner`, matching the Solidity reference `ecrecover`
behavior. Previously, a crafted signature that somehow recovered to
`address(0)` could have been accepted if `owner` was also `address(0)`.

**New tests**

- `test_permit_zero_address_recovery_reverts` — verifies
`InvalidSignature` is returned when ecrecover yields the zero address
- `test_permit_domain_separator_changes_with_chain_id` — verifies the
EIP-712 domain separator differs across chain IDs (fork safety)

---------

Co-authored-by: Amp <amp@ampcode.com>
@howydev howydev enabled auto-merge February 23, 2026 21:36
@howydev howydev added this pull request to the merge queue Feb 23, 2026
Merged via the queue into main with commit fbd464e Feb 23, 2026
25 checks passed
@howydev howydev deleted the howy/add-permit branch February 23, 2026 21:58
@jenpaff jenpaff added the T2 label Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants